package com.zcxy.fast.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;

import com.zcxy.fast.anotation.Log;
import com.zcxy.fast.bean.PageQuery;
import com.zcxy.fast.bean.Response;
import com.zcxy.fast.entity.SysDict;
import com.zcxy.fast.service.ISysDictService;
import com.zcxy.fast.vo.SysDictVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 平台-字典表Controller
 *
 * @author zcc
 * @email  860474958@qq.com
 * @date   2020-12-18 15:05:58
 */
@RestController
@RequestMapping("/api/sysDict")
@Api(tags = "平台-字典表管理")
@Slf4j
public class SysDictController {
    @Autowired
    private ISysDictService iSysDictService;

    @Log("获取平台-字典表数据--分页")
    @PostMapping(value = "/queryPageList")
    @ApiOperation(value = "获取(平台-字典表)分页数据列表", notes = "获取(平台-字典表)分页数据列表")
    public Response<IPage<SysDictVo>> queryPageList(@RequestBody PageQuery<SysDict> queryVo) {
        return Response.ok(iSysDictService.queryPageList(queryVo));
    }

    @Log("获取平台-字典表数据-列表")
    @GetMapping(value = "/queryList")
    @ApiOperation(value = "获取平台-字典表数据-列表", notes = "获取平台-字典表数据-列表")
    public Response<List<SysDictVo>> queryList(SysDict sysDict) {
        return Response.ok(iSysDictService.queryList( sysDict));
    }


    @Log("添加平台-字典表数据")
    @PostMapping(value = "/add")
    @ApiOperation(value = "添加平台-字典表数据", notes = "添加平台-字典表数据")
    public Response addSysDict(@RequestBody @Validated @NotNull SysDict queryVo) {
        iSysDictService.addSysDict(queryVo);
        return Response.ok();
    }


    @Log("修改平台-字典表数据")
    @PostMapping(value = "/update")
    @ApiOperation(value = "修改平台-字典表数据", notes = "修改平台-字典表数据")
    public Response updateSysDict(@RequestBody @Validated @NotNull SysDict queryVo) {
        iSysDictService.updateSysDict(queryVo);
        return Response.ok();
    }


    @Log(value = "批量删除平台-字典表")
    @ApiOperation("批量删除平台-字典表")
    @PostMapping("/dels")
    public Response deleteByIds(@RequestBody List<String> ids) {
        iSysDictService.removeAllSysDict(ids);
        return Response.ok();
    }



}
